<?php
/**
 *
 * @package avp
 * @version $Id: $
 * @copyright (c) 2006 Jan-Willem van Ganswijk, Stefan van Essen
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
define('IN_SCRIPT', 'TRUE'); //Voor de evil haxx0rz.

$root = "../";

include($root . 'includes/common.inc.php');
include($root . 'includes/lang.inc.php');
include($root . 'includes/session.class.php');
include($root . 'includes/template.class.php');
include($root . 'includes/admin.inc.php');

$session = new sessionWrapper();
$template = new template( $CONFIG['theme'] );

$lang = read_langfiles('admin_common');

if (isset($_GET['login'])) {
    if ($_POST['usecookie'] == 1) {
        $use_cookie = true;
    } else {
        $use_cookie = false;
    }
    if ($session->login(addslashes($_POST['username']), addslashes($_POST['password']), $use_cookie)) {
        header('location: index.php');
        die(print_message($lang['TITLE_LOGIN'], $lang['LOGIN_SUCCES'], 'index.php', true));
    } else {
        die(print_error($lang['ERROR_FALSELOGIN'], 'login.php', true));
    }
} elseif (isset($_GET['logout'])) {
    $session->logout();
    die(print_message($lang['TITLE_LOGIN'], $lang['LOGOUT_SUCCES'], 'login.php', true));
}

$template->set_title($lang['TITLE_LOGIN']);
$template->add_templates('admin_header_small,admin_login,admin_footer');
$template->make_page();

?>